#ifndef DRAW_H_
#define DRAW_H_

#include <GL/glew.h>

#include "shadersystem.h"
#include "viewmatrix.h"
#include "util.h"

//#define DRAW_OPENGL_2
#define DRAW_OPENGL_3

#ifdef DRAW_OPENGL_2 
#define CLEAR_BUFFER \
 glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); \
 glLoadIdentity()
 
#define PUSH_MATRIX \
 glPushMatrix()
 
#define POP_MATRIX \
 glPopMatrix()
 
#define LOAD_IDENTITY \
 glLoadIdentity()
 
#define SWAP_BUFFERS SDL_GL_SwapBuffers()
 
#endif

#ifdef DRAW_OPENGL_3
#define CLEAR_BUFFER \
 glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); \
 Draw::BindVertexAttribPointer(); \
 Draw::LoadIdentity()
 
#define PUSH_MATRIX \
 Draw::Push()
 
#define POP_MATRIX \
 Draw::Pop()
 
#define LOAD_IDENTITY \
 Draw::LoadIdentity()
 
#define SWAP_BUFFERS \
Draw::UnbindVertexAttribPointer(); \
SDL_GL_SwapBuffers()
 
#endif

namespace Draw
{
	
	void InitDrawLists();
	void FreeDrawLists();
	
	void RawQuad();
	
	void Quad( double, double, double, int, int );

	void TexturedQuad( double, double, int, int );
	void TexturedQuad( Vector2D, int, int );
	
	
	//NEW:
	
	void SetSTOffsets( float, float, float, float );
	void SetSTMul( float, float );
	void BindVertexAttribPointer();
	void UnbindVertexAttribPointer();
	
	void InitShaderValues( int );
	
	void DisableTextures();
	void EnableTextures();
	
	void SetBlankPixel( GLuint );
	void SetShaderProgram( int );
	
	void FreeOpenGL3Context();
	void SetShaderSystem( CShaderSystem *, int );
	
	void LoadIdentity();
	void BindTexture( GLuint );
	void InitOpenGL3Context();
	void VertexBuffer();
	
	void Push();
	void Pop();
	
	void Scale( float, float, float );
	void Translate( float, float, float );
	
	void Color4f( float, float, float, float );
	
	void GetMatrix( float * );
	
	void SetCull( bool );
	
	float * GetTranslate();
	
};


#endif
